$(function(){
	//个人用户列表查询 
	selectUserList();
});

//个人用户列表查询 
function selectUserList(){
	$.ajax({
		type : "POST",
		url : "/userAdmin/userList/search/",
		async : false,
		success:function(data){
			var userList = data.userList;
			var $tbody = $("#userList tbody");
			if(userList.length > 0) {
				for(var i=0;i<userList.length;i++){
					var userInfo = userList[i];
					var loginNum = setLoginNum(userInfo);
					var $tr = '<tr class="odd">';
					$tr += '<td>'+checkNull(loginNum)+'</td>';
					$tr += '<td>'+checkNull(userInfo.phone)+'</td>';
					$tr += '<td>'+parseFloat(userInfo.accountMoney).toFixed(2)+'元</td>';
					$tr += '<td>'+checkNull(userInfo.belongCompanyName)+'</td>';
					$tr += '<td>'+checkNull(userInfo.companyDomainName)+'</td>';
					$tr += '<td>'+checkNull(userInfo.provinceCodeName) + checkNull(userInfo.cityCodeName) + checkNull(userInfo.areaCodeName) + checkNull(userInfo.address)+'</td>';
					$tr += '<td><button type="button" class="btn btn-primary" onclick="toDetail('+userInfo.userId+');">查看详情</button></td>';
					$tr += '</tr>';
					$tbody.append($tr);
				}
			}else {
				var $tr = '<tr class="odd"><td colspan="7">暂无数据！</td></tr>';
				$tbody.append($tr);
				alert("查询失败！")
			}
		}
	})
}

//查看详情
function toDetail(userId){
	location.href="/userAdmin/userDetail/"+userId;
}

//检测非空
function checkNull(para){
	if(para == null){
		return "";
	}else{
		return para;
	}
}

//设置登陆账号
function setLoginNum(userInfo){
	if(userInfo.userEmail != "" && userInfo.userEmail != null){
		return userInfo.userEmail;
	}else if(userInfo.userTel != "" && userInfo.userTel != null){
		return userInfo.userTel;
	}else{
		return "";
	}
}







